package com.augurit.tool.codeBuilder;

import java.util.Map;

public class Main {

    public static  void  main(String args[]) throws Exception {
        String[] tableNames = {"nf_safety_job_gen_column","nf_safety_job_gen_where","nf_safety_job_gen_setting"/*,"rc_applyprocess","rc_attachfile",
        "rc_black_list","rc_black_lisst_detail","rc_cartitem","rc_layer","rc_monitor_rule","rc_soft"*/};
        for (String tableName : tableNames) {
            CodeCommon my=new CodeCommon(tableName);
            Main main=new Main();
            main.setMy(my);
            main.genarate(tableName);
        }
    }

    private CodeCommon my;

    public CodeCommon getMy() {
        return my;
    }

    public void setMy(CodeCommon my) {
        this.my = my;
    }

    public void genarate(String tableName) throws  Exception{
        /*CodeCommon my;
        //表名必须使用下划线分隔！！
                *//*String tableName="erp_report_sev_contract_lw";
        String tableName="crm_contract_info_value_item";*//*
        my=new CodeCommon(tableName);*/
        my.init(tableName);
//        my=new CodeCommon("erp_mgmt_okr_target");
//        my.onUsingTableNames="crm_base_client_info,crm1_base_linkman_info,crm1_proj_base_info,spl1_base_supplier_info,erp_mgmt_okr_task,";
//        if(my.hasTableOnUsing(my.getTableName())){
//            System.out.println("该表目前正在使用，重新覆盖代码或许会对系统造成较大影响！\n 请尽量换个tablename来进行代码生成....");
//            return;
//        }
        System.out.println(my.getTableName());
        //setTableNameDesc(createTableNameDesc().substring(0,createTableNameDesc().length()-1));
//        setTableNameDesc("项目计划模板节点"); //如果数据库中表名没有描述,则自己手动赋值给tablenamedesc
        //setTableNameDesc("项目管理信息"); //如果数据库中表名没有描述,则自己手动赋值给tablenamedesc
        Map root=my.builTemplateForOneTable();
       /* if(false==(validCodeConflict(root,tableName))){
            System.out.println("该表目前正在使用，重新覆盖代码或许会对系统造成较大影响！\n 请尽量换个tablename来进行代码生成....");
            return;
        }*/
        my.createCodeForSqlMapperXml(root);
        my.createCodeForVo(root);        //居然有人把这句话注释了然后提交，害我编辑到一半发现不对然后又要备份文件重新生成！
        my.createCodeForMapper(root);
        my.createCodeForService(root);
        my.createCodeForServiceImpl(root);
        my.createCodeForController(root);
//        my.createCodeForJspFile(root);
//        my.createCodeForJsFile(root);
    }
}
